//
//  TermsOfServiceView.swift
//  CMB250716
//
//  Created by Trae AI on 2025/01/16.
//

import SwiftUI

struct TermsOfServiceView: View {
    @EnvironmentObject var dataManager: DataManager
    @Environment(\.dismiss) private var dismiss
    
    var body: some View {
        NavigationView {
            ZStack {
                Color(red: 0.08, green: 0.08, blue: 0.08)
                    .ignoresSafeArea()
                
                ScrollView {
                    VStack(alignment: .leading, spacing: 20) {
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "Cu Mr Bull 服务条款" : "Cu Mr Bull Terms of Service")
                                .font(.title2)
                                .fontWeight(.bold)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? "最后更新：2024年7月" : "Last Updated: July 2024")
                                .font(.caption)
                                .foregroundColor(.gray)
                        }
                        
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "1. 服务说明" : "1. Service Description")
                                .font(.headline)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? 
                                "Cu Mr Bull 是一款提供韩式料理预订和配送服务的移动应用程序。通过使用本应用，您同意遵守以下服务条款。" :
                                "Cu Mr Bull is a mobile application that provides Korean cuisine reservation and delivery services. By using this application, you agree to comply with the following terms of service.")
                                .font(.body)
                                .foregroundColor(.gray)
                        }
                        
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "2. 用户责任" : "2. User Responsibilities")
                                .font(.headline)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? 
                                "用户需要提供准确的个人信息，并对账户安全负责。禁止使用本应用进行任何违法活动。" :
                                "Users must provide accurate personal information and are responsible for account security. Any illegal activities using this application are prohibited.")
                                .font(.body)
                                .foregroundColor(.gray)
                        }
                        
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "3. 隐私保护" : "3. Privacy Protection")
                                .font(.headline)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? 
                                "我们承诺保护您的个人隐私，详细信息请参阅我们的隐私政策。" :
                                "We are committed to protecting your personal privacy. For details, please refer to our privacy policy.")
                                .font(.body)
                                .foregroundColor(.gray)
                        }
                        
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "4. 服务变更" : "4. Service Changes")
                                .font(.headline)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? 
                                "我们保留随时修改或终止服务的权利，恕不另行通知。" :
                                "We reserve the right to modify or terminate services at any time without prior notice.")
                                .font(.body)
                                .foregroundColor(.gray)
                        }
                        
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "5. 免责声明" : "5. Disclaimer")
                                .font(.headline)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? 
                                "本应用按'现状'提供服务，我们不对服务的连续性、准确性或完整性做出保证。" :
                                "This application provides services 'as is'. We do not guarantee the continuity, accuracy, or completeness of the service.")
                                .font(.body)
                                .foregroundColor(.gray)
                        }
                        
                        VStack(alignment: .leading, spacing: 15) {
                            Text(dataManager.currentLanguage == "zh" ? "6. 联系我们" : "6. Contact Us")
                                .font(.headline)
                                .foregroundColor(.white)
                            
                            Text(dataManager.currentLanguage == "zh" ? 
                                "如有任何问题，请通过应用内客服或邮件联系我们。" :
                                "If you have any questions, please contact us through in-app customer service or email.")
                                .font(.body)
                                .foregroundColor(.gray)
                        }
                    }
                    .padding()
                }
            }
            .navigationTitle(dataManager.currentLanguage == "zh" ? "服务条款" : "Terms of Service")
            .navigationBarTitleDisplayMode(.inline)
            .toolbar {
                ToolbarItem(placement: .navigationBarTrailing) {
                    Button(dataManager.currentLanguage == "zh" ? "完成" : "Done") {
                        dismiss()
                    }
                    .foregroundColor(.blue)
                }
            }
        }
    }
}

#Preview {
    TermsOfServiceView()
        .environmentObject(DataManager.shared)
}